#include<iostream>
using namespace std;
const int N = 1010;
int m, n;
int q;
int arr[N][N], d[N][N], sum[N][N];
int main()
{
	cin >> n >> m >> q;
	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < m + 1; j++) {
			cin >> arr[i][j];
		}
	}
	while (q--)
	{
		int x1, y1, x2, y2, c;
		cin >> x1 >> y1 >> x2 >> y2 >> c;
		d[x1][y1] += c;
		d[x1][y2 + 1] -= c;
		d[x2+1][y1] -= c;
		d[x2 + 1][y2 + 1] += c;
	}
	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < m + 1; j++) {
			sum[i][j] = d[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
			cout << sum[i][j] + arr[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}
